//
//  KFViewController.m
//  TQY
//
//  Created by 甘世清 on 2024/8/25.
//

#import "KFViewController.h"
#import <MessageUI/MessageUI.h>
@interface KFViewController ()<MFMailComposeViewControllerDelegate>

@end

@implementation KFViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.zx_navTitle = SQNSLocalString(@"客服");
}

- (void)SQ_UIViewForSelfView{
    UILabel * label = [[UILabel alloc]init];
    label.text = SQNSLocalString(@"联系邮箱:");
    label.textColor = UIColor.grayColor;
    label.font = FONT_REGULAR(14);
    [self.view addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view).offset(20);
            make.top.equalTo(self.zx_navBar.mas_bottom).offset(20);
    }];
    UILabel * label1 = [[UILabel alloc]init];
    label1.text = SQNSLocalString(@"xnvtxd@163.com");
    label1.textColor = SQColor3DA59D;
    label1.font = FONT_MEDIUM(18);
    [self.view addSubview:label1];
    [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view).offset(20);
            make.top.equalTo(self.zx_navBar.mas_bottom).offset(60);
    }];
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.layer.cornerRadius = 4;
    btn.layer.masksToBounds = YES;
    btn.titleLabel.font = FONT_REGULAR(14);
    [btn addTarget:self action:@selector(SQ_ButtonClick) forControlEvents:UIControlEventTouchUpInside];
    btn.backgroundColor = SQColor3DA59D;
    [btn setTitle:SQNSLocalString(@"复制邮箱") forState:normal];
    [self.view addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(SCREEN_WIDETH-40);
        make.height.mas_equalTo(50);
        make.centerX.equalTo(self.view);
        make.bottom.equalTo(self.view.mas_bottom).offset(-FootHeight-50);
    }];
    
}
-(void)SQ_ButtonClick{
    if ([MFMailComposeViewController canSendMail]) {
        MFMailComposeViewController *mailComposeVC = [[MFMailComposeViewController alloc] init];
        [mailComposeVC setSubject:@"验证码异常"];
        [mailComposeVC setToRecipients:@[@"xnvtxd@163.com"]];
        [mailComposeVC setCcRecipients:@[@"xnvtxd@163.com"]];
        [mailComposeVC setBccRecipients:@[@"xnvtxd@163.com"]];
        [mailComposeVC setMessageBody:@"登录账号时无法获取到短信验证码" isHTML:NO];
        mailComposeVC.mailComposeDelegate = self;
        [self presentViewController:mailComposeVC animated:YES completion:nil];
    } else {
        UIPasteboard *pab = [UIPasteboard generalPasteboard];
        pab.string = @"xnvtxd@163.com";
          if (pab == nil) {
              [YJProgressHUD showMsgWithoutView:SQNSLocalString(@"复制失败")];
          } else {
              [YJProgressHUD showMsgWithoutView:SQNSLocalString(@"复制成功")];
          }
    }
   

}
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(nullable NSError *)error{
    [controller dismissViewControllerAnimated:YES completion:nil];
}
@end
